namespace PEMMITER
{
	const int PP_DX=0;
	const int PP_DY=2;
	const int PP_DZ=4;
	const int PP_X=6;
	const int PP_Y=8;
	const int PP_Z=10;
	const int PP_D2X=12;
	const int PP_D2Y=14;
	const int PP_D2Z=16;
	const int PP_LIFE=18;
	const int PP_PARTICLE_COUNT=20;
	const int PP_DR=22;
	const int PP_DG=24;
	const int PP_DB=26;
	const int PP_DA=28;
	const int PP_R=30;
	const int PP_G=32;
	const int PP_B=34;
	const int PP_A=36;
	const int PP_D2R=38;
	const int PP_D2G=40;
	const int PP_D2B=42;
	const int PP_D2A=44;
	const int PP_CREATE=46;
	const int PP_MAXSIZE=48;

	std::map<std::string,int> PP_LINKS;
}

class Particle
{
public:
	float x[4];
	float dx[4];
	float d2x[4];

	float r[4];
	float dr[4];
	float d2r[4];

	float size;
	float l;

	int Update();
	void Draw();

	float DistSq();
};

typedef std::list<Particle*> pslist;

class PConteiner
{
	int count;
	int pmax;
	Particle* arr;

	float *params;

	float *pvertices;
	float *pcolors;

	float r(int val);

	float sqrad;
public:
	PConteiner(int cnt,float *p);
	~PConteiner();

	void Update();
	inline void Draw();

	int GetCountTris();

	void SetParam(int param,float value);
	void SetParam(int param,float minvalue,float maxvalue);

	float GetRadius();
};

class PEmmiter
{
	pslist ps;
	float *params;
	void init();

	std::map<const Entity*,PConteiner*> instances;
public:
	PEmmiter();
	PEmmiter(const char *filename);
	~PEmmiter();
	void Update();
	int Draw(const Entity* ent,float factor);

	void SetParam(int param,float value);
	void SetParam(int param,float minvalue,float maxvalue);

	void RemoveInstance(const Entity* inst);
	void AddInstance(const Entity* inst);

	void SetParamEnt(const Entity* ent,int param,float value);
	void SetParamEnt(const Entity* ent,int param,float minvalue,float maxvalue);

	Vector3D get_look(); 
	
	float GetCurrentRadius(const Entity* ent);
};